home *** CD-ROM | disk | FTP | other *** search
- /*
- * List the status of the various drives that PC-DOS knows about.
- *
- * Characteristics that are checked for are:
- * - does DOS know about the drive
- * - does the drive support removable media
- * - is the drive redirected to a network device
- * - what network device is a drive directed to
- *
- *
- *
- * version 1.0 5may87 mgm - initial release
- * 1.1 mgm - added pc.h in the includes.
- *
- */
-
- #include <stdlib.h>
- #include <string.h>
- #include <dos.h>
- #include <pc.h>
-
-
- #define HELLO "DRIVES version 1.1"
-
- char lbuf[128];
- char nbuf[128];
-
- char *prns[] = { "prn", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", NULL } ;
-
-
- void main (argc, argv)
- int argc;
- char *argv[];
- {
- int i;
- int rc;
- char dbuf[5];
-
-
- cprintf ("%s\n\n", HELLO);
-
- for (i = 1; i < 27; i++) { /* check disk drive status */
-
- rc = isnetdc (i); /* network drive? */
- switch (rc) {
-
- case 0:
- cprintf (" %c: local drive", i - 1 + 'A');
- if (0 == isfixmed (i))
- cprintf (", removable media");
- cprintf (".\n");
- break;
-
- case 1:
- sprintf (dbuf, "%c:", i - 1 + 'A');
- rc = getredir (dbuf, lbuf, nbuf);
- if (rc == 0) cprintf (" %s network drive, redirected to: %s.\n",
- lbuf, nbuf);
- break;
-
- default:
- break;
-
- } /* switch (rc) */
-
- } /* for... */
-
-
- if (isnet () && isneton ()) {
-
- cprintf ("\n");
-
- for (i = 0; prns[i] != NULL; i++) { /* loop through printer table */
-
- rc = getredir (prns[i], lbuf, nbuf);
- if (rc == 0)
- cprintf (" %s redirected to: %s.\n", lbuf, nbuf);
-
- } /* for ... */
-
- } /* if (isnet... */
-
-
- exit (0);
-
- } /* main () */
-
-
- /******************************************************************************
- * Does the device in question support removable media?
- * returns: 0 - removable
- * 1 - fixed
- * 0x0F - error
- */
- int isfixmed (drv)
- int drv;
- {
- union REGS reg;
-
- reg.h.ah = 0x44;
- reg.h.al = 0x08;
- reg.h.bl = drv;
-
- intdos (®, ®);
-
- return (reg.x.ax);
-
- } /* int isfixmed */
-
-
-
- /******************************************************************************
- * obtain the redirection for a network device
- */
- int getredir (devnam, lclbuf, netbuf)
- char *devnam;
- char *lclbuf;
- char *netbuf;
- {
- int i;
- int rc;
- int rdtype;
- int parm;
- char lname[128];
-
- extern int _OSERR;
-
- _OSERR = 0;
- rc = -1;
- for (i = 0; _OSERR != 18; i++) { /* loop through redirection table */
-
- rdtype = pcngdr (i, lname, netbuf, &parm);
-
- if (rdtype == 4 || rdtype == 3) { /* disk: 4, printer: 3 */
- if (0 == stricmp (lname, devnam)) {
- strcpy (lclbuf, lname);
- rc = 0;
- break;
- } /* if (0 == stricmp... */
- } /* if (rdtype */
-
- } /* for... */
-
- return (rc);
-
- } /* int getredir () */
-